using System.Windows.Forms;
using CodePlex.DnD4eCampaignManager.Presentation.ViewInterfaces;

namespace CodePlex.DnD4eCampaignManager.CampaignManagerControlLibrary
{
    public class CustomOpenFileControl : IOpenFileView
    {
        private readonly OpenFileDialog _openFileDialog;
        private DialogResult _lastDialogResult;

        public CustomOpenFileControl()
        {
            _openFileDialog = new OpenFileDialog();
        }

        public bool CheckIfFileExists
        {
            get { return _openFileDialog.CheckFileExists; }
            set { _openFileDialog.CheckFileExists = value; }
        }

        public string FileFilter
        {
            get { return _openFileDialog.Filter; }
            set { _openFileDialog.Filter = value; }
        }

        public int FilterIndex
        {
            get { return _openFileDialog.FilterIndex; }
            set { _openFileDialog.FilterIndex = value; }
        }

        public bool IsDialogResultCancel
        {
            get { return _lastDialogResult == DialogResult.Cancel; }
        }

        public bool IsDialogResultOk
        {
            get { return _lastDialogResult == DialogResult.OK; }
        }

        public bool RestoreDirectory
        {
            get { return _openFileDialog.RestoreDirectory; }
            set { _openFileDialog.RestoreDirectory = value; }
        }

        public string SelectedFilePath
        {
            get { return _openFileDialog.FileName; }
        }

        public void ShowDialog()
        {
            _lastDialogResult = _openFileDialog.ShowDialog();
        }
    }
}